package com.suxin.thread.schedulev3.executor;

import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Tang
 * @classname SlaverExecutor
 * @description [  ]
 * @date 2021/6/11 16:46
 */
public class SlaverExecutor {

    private static ThreadPoolExecutor poolExecutor = null;

    static {
        poolExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors(),
                Runtime.getRuntime().availableProcessors() + 1,
                500, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(30),
                new CustomizableThreadFactory("SlaverExecutor-"));
    }

    public static void exec(RunnableJob runnableJob) {
        poolExecutor.execute(runnableJob);
    }

}